function Test-Type
{
    [CmdletBinding()]
    param (
        [parameter(Position=0, ValueFromPipeline=$True)]
        [String]$Name,
        [parameter()]
        [switch]$Throw
    )
    
    begin 
    { 
        $empty = $true 
        
        function ThrowOrReturn([bool]$ret)
        {
            if ($Throw) {
                if (!$ret) {
                    throw "Type {0} is not loaded" -f
                        ($Name | ?? "[null]")
                }
            }
            else { $ret } 
        }
    }

    process
    {        
        $empty = $false    
        
        try 
        {    
            ThrowOrReturn ($Name -as [Type])
        }
        catch { ThrowOrReturn $false }
    }            
    
    end 
    {
        if ($empty) { ThrowOrReturn $false }        
    }
}